package edu.nf.takeoutdemo.model.converter;

import edu.nf.takeoutdemo.model.dto.EmployeeDTO;
import edu.nf.takeoutdemo.model.dto.EmployeeLoginDTO;
import edu.nf.takeoutdemo.model.entity.Employee;
import edu.nf.takeoutdemo.model.vo.EmployeeLoginVO;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 *
 * @author zjl
 * @date 2025/10/24
 */
@Mapper(componentModel = "spring")
public interface EmployeeConverter {

    @Mappings({
            @Mapping(source = "username",target = "username"),
            @Mapping(source = "password",target = "password"),
    })
    EmployeeLoginDTO toEmployeeLoginDTO(Employee employee);

    @InheritInverseConfiguration(name = "toEmployeeLoginDTO")
    Employee toEmployee(EmployeeLoginDTO employeeLoginDTO);

    @Mappings({
            @Mapping(source = "id",target = "id"),
            @Mapping(source = "username",target = "username"),
            @Mapping(source = "name",target = "name")
    })
    EmployeeLoginVO toEmployeeLoginVO(Employee employee);


    @Mappings({
            @Mapping(source = "id",target = "id"),
            @Mapping(source = "name",target = "name"),
            @Mapping(source = "username",target = "username"),
            @Mapping(source = "phone",target = "phone"),
            @Mapping(source = "sex",target = "sex"),
            @Mapping(source = "idNumber",target = "idNumber")
    })
    EmployeeDTO toEmployeeDTO(Employee employee);

    @InheritInverseConfiguration(name = "toEmployeeDTO")
    Employee toEmployee(EmployeeDTO employeeDTO);
}
